package org.jackysoft.service.impl;

import java.util.Collection;

import javax.annotation.Resource;

import org.jackysoft.data.AbstractDataProvider;
import org.jackysoft.entity.OsRuntimeContext;
import org.jackysoft.mapper.OsRuntimeContextMapper;
import org.jackysoft.service.OsRuntimeContextService;
import org.jackysoft.service.OsWorkflowRunnerService;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

@Service
public class OsRuntimeContextServiceImpl extends
		AbstractDataProvider<OsRuntimeContext> implements
		OsRuntimeContextService {

	private @Resource OsWorkflowRunnerService workflowService;
	@Resource
	OsRuntimeContextMapper mapper;

	public OsRuntimeContextServiceImpl() {
		super();
	}

	@Override
	public void save(Collection<OsRuntimeContext> sts)
			throws DataAccessException {
		
		for(OsRuntimeContext st:sts){
			if(st==null)continue;
			mapper.inert(st);
			
		}

	}


	@Override
	public Collection<OsRuntimeContext> getsByName(String workflowName)
			throws DataAccessException {
		Collection<OsRuntimeContext> list = mapper.findByRefname(workflowName);
		return list;
	}

		
	@Override
	public OsRuntimeContext findOne(long refid, int actionId, long stepId)
			throws DataAccessException {
		
		OsRuntimeContext ws =mapper.findOfOne(refid, actionId, stepId);
				
		return ws;
	}

	@Override
	public OsRuntimeContext findOne(String refname, int actionId, long stepId)
			throws DataAccessException {
		return mapper.findOneByPk(refname, actionId, stepId);
	}

}
